package com.retail.proxy.service.impl;

import com.retail.proxy.entity.vo.ProxyOrderAchieveVo;
import com.retail.core.entity.ParamReq;
import com.retail.proxy.entity.request.ProxyOrderAchieveRequest;
import com.retail.proxy.mapper.ProxyOrderAchieveMapper;
import com.retail.proxy.service.ProxyOrderAchieveService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
* 业绩 Service impl
* @author Administrator
*/
@Service
public class ProxyOrderAchieveServiceImpl implements ProxyOrderAchieveService {

   @Resource
   private ProxyOrderAchieveMapper proxyOrderAchieveMapper;

   @Override
   public ProxyOrderAchieveVo getModel(Long id) {
      return  proxyOrderAchieveMapper.getModel(id);
   }

   @Transactional
   @Override
   public Long save(ProxyOrderAchieveRequest proxyOrderAchieveRequest) {
      proxyOrderAchieveMapper.save(proxyOrderAchieveRequest);
      return proxyOrderAchieveRequest.getId();
   }

   @Transactional
   @Override
   public Long update(ProxyOrderAchieveRequest proxyOrderAchieveRequest) {
      proxyOrderAchieveMapper.update(proxyOrderAchieveRequest);
      return proxyOrderAchieveRequest.getId();
   }

   @Override
   public List<ProxyOrderAchieveVo> listPage(ParamReq<ProxyOrderAchieveRequest> params) {
      params.setStartIndex((params.getCurrent() -1 ) * params.getSize());
      return proxyOrderAchieveMapper.listPage(params);
   }

   @Override
   public Integer countPage(ParamReq<ProxyOrderAchieveRequest> params) {
       return proxyOrderAchieveMapper.countPage(params);
   }

   @Override
   public Integer updateDelFlagById(Long id, Integer delFlag) {
       return proxyOrderAchieveMapper.updateDelFlagById(id, delFlag);
   }

    @Override
    public ProxyOrderAchieveVo findAchieveByCategoryIdAndAchieveType(Long proxyCategoryId, int achieveType) {
        return proxyOrderAchieveMapper.findAchieveByCategoryIdAndAchieveType(proxyCategoryId, achieveType);
    }

   @Override
   public ProxyOrderAchieveVo findAchieveByCategoryIdAndAchieveTypeAndMonth(Long proxyCategoryId, int achieveType, Integer achieveMonth) {
      return proxyOrderAchieveMapper.findAchieveByCategoryIdAndAchieveTypeAndMonth(proxyCategoryId,achieveType,achieveMonth);
   }
}
